﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Model.Repositories;
using Domain.Model.Vehiculos;
using Domain.Model.Base;

namespace Infrastructure.Base.InMemory
{

    public class MVehiculoRepository : VehiculoRepository
    {
        private Dictionary<VehiculoId, Vehiculo> lista;

        public MVehiculoRepository()
        {
            this.lista = new Dictionary<VehiculoId, Vehiculo>();

        }


        public override void Insert(Vehiculo entity)
        {
            this.lista.Add((VehiculoId)entity.Identity, entity);
        }

        public override Vehiculo FromId(ObjectIdentity id)
        {
            return this.lista[(VehiculoId)id];
        }

        public override ObjectIdentity NextIdentity()
        {
            return new VehiculoId(Guid.NewGuid().ToString().ToUpper());
        }

        public override void Update(Vehiculo entity)
        {
            throw new NotImplementedException();
        }

        public override void Remove(ObjectIdentity id)
        {
            this.lista.Remove((VehiculoId)id);
        }

        public override List<Vehiculo> All()
        {
            return new List<Vehiculo>(this.lista.Values);
        }

        public override int Count()
        {
            return this.lista.Values.Count;
        }
    }
}
